﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Windows.Forms;

using AimGameLibrary;

namespace AimGameEngine.NodeEditorObject
{
    partial class PropretyBody : Form
    {
        NodeBody bodydata;
        public PropretyBody(NodeBody bodydata)
        {
            InitializeComponent();

            this.bodydata = bodydata;
            this.numX.Value = (decimal)bodydata.myvector2.X;
            this.numY.Value = (decimal)bodydata.myvector2.Y;
            this.numWidth.Value = (decimal)bodydata.mysize.X;
            this.numHeight.Value = (decimal)bodydata.mysize.Y;
            this.numForce.Value = (decimal)bodydata.myforce;
            this.InputMode.SelectedItem = bodydata.InputMode.ToString();
           
        }

        private void okButton_Click(object sender, EventArgs e)
        {
            String tempString = (String)this.InputMode.SelectedItem;

            if (bodydata.InputMode == NodeInputMode.None)
            {
                bodydata.myvector2.X = (float)this.numX.Value;
                bodydata.myvector2.Y = (float)this.numY.Value;
                bodydata.mysize.X = (float)this.numWidth.Value;
                bodydata.mysize.Y = (float)this.numHeight.Value;
                bodydata.myforce = (float)this.numForce.Value;
            }


            String tempOldMode = bodydata.InputMode.ToString();

            if (tempString == NodeInputMode.Float_5.ToString())
                bodydata.InputMode = NodeInputMode.Float_5;
            else bodydata.InputMode = NodeInputMode.None;

            if(tempOldMode != tempString)
                bodydata.SetupProprety();
        }

        private void InputMode_SelectedIndexChanged(object sender, EventArgs e)
        {
            String tempString = (String)this.InputMode.SelectedItem;

            if (tempString != NodeInputMode.None.ToString())
            {
                numX.ReadOnly = true;
                numY.ReadOnly = true;
                numWidth.ReadOnly = true;
                numHeight.ReadOnly = true;
                numForce.ReadOnly = true;
            }
            else
            {
                numX.ReadOnly = false;
                numY.ReadOnly = false;
                numWidth.ReadOnly = false;
                numHeight.ReadOnly = false;
                numForce.ReadOnly = false;
            }
        }

    }
}
